package pl.wroc.uni.ii.puzzleWS.data;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

public enum ScoreDao { INSTANCE;

	public void persist(Score score) {
		synchronized (this) {
			EntityManager em = EMFService.get().createEntityManager();
			em.persist(score);
			em.close();
		}
	}
	
	public List<Score> selectHighScores() {
		EntityManager em = EMFService.get().createEntityManager();

		Query q = em.createQuery("select m from Score m");
		List<Score> scores = q.getResultList();
		return scores;
	}
}
